<template>
  <el-dialog
    title="活动审核"
    :close-on-click-modal="false"
    :visible.sync="visible"
    width="40%"
  >
    <el-form
      @submit.native.prevent
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      :label-width="this.$i18n.t('language') === 'language' ? '130px' : '80px'"
    >
      <el-form-item :label="$t('components.processingStatus')" prop="status">
        <el-radio-group v-model="dataForm.status">
          <el-radio :label="5">{{ $t("productComm.pass") }}</el-radio>
          <el-radio :label="6">{{ $t("productComm.noPass") }}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        v-if="dataForm.status === 6"
        :label="$t('components.denialReason')"
        prop="refuseReason"
      >
        <el-input
          type="textarea"
          :autosize="{ minRows: 4, maxRows: 10 }"
          maxlength="200"
          size="small"
          v-model="activityCheckMsg"
        ></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <div class="default-btn" @click="visible = false">
        {{ $t("remindPop.cancel") }}
      </div>
      <div :class="['default-btn primary-btn']" @click="dataFormSubmit()">
        {{ $t("group.confirmReview") }}
      </div>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        status: 1,
      },
      activityCheckMsg: "",
      id: 0,
      dataRule: {},
    };
  },
  methods: {
    init({ id }) {
      this.id = id;
      this.visible = true;
      this.dataForm.status = 5;
      this.activityCheckMsg = "";
    },
    // 表单提交
    dataFormSubmit() {
      if (this.dataForm.status === 6) {
        if (!this.activityCheckMsg) {
          this.$message.warning(this.$i18n.t("shopProcess.auditTip3"));
          return;
        }
        let reg = /^\s+$/g;
        if (reg.test(this.activityCheckMsg)) {
          this.$message.warning(this.$i18n.t("shopProcess.inputAllSpace"));
          return;
        }
      } else {
        this.activityCheckMsg = "";
      }

      console.log({
        id: this.id,
        activityCheckState: this.status, //5.审核通过6.审核失败
        activityCheckMsg: this.activityCheckMsg,
      });
      this.visible = false;
      this.$http({
        url: this.$http.adornUrl(`/platform/activity/checkActivity`),
        method: "get",
        params: this.$http.adornParams({
          id: this.id,
          activityCheckState: this.dataForm.status, //5.审核通过6.驳回
          activityCheckMsg: this.activityCheckMsg,
        }),
      }).then(({ data }) => {
        this.$message({
          message: this.$i18n.t("remindPop.success"),
          type: "success",
          duration: 1000,
          onClose: () => {
            this.visible = false;
            this.$router.back();
          },
        });
        this.visible = false;
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.content-color {
  color: #155bd4;
  word-break: break-word;
}
</style>
